﻿using EyFramework.ORM;
using ShuJuGj.Entity;
using SqlSugar;
using System;
using System.Collections.Generic;

namespace tjyyjl.Core.Dao
{
    /// <summary>
    ///  TJ_TJYYJL表的数据库操作
    /// </summary>
    public class TjTjyyjlDao : BaseDaoTj<TjTjyyjl>, ITjTjyyjlDao
    {
        public List<TjTjyyjl> GetListBy(Inquire inquire)
        {
            return Db.Queryable<TjTjyyjl>()
                .WhereIF(!string.IsNullOrEmpty(inquire.checkDateStart) && !string.IsNullOrEmpty(inquire.checkDateEnd), p => SqlFunc.Between(p.checkDate.Value, Convert.ToDateTime(inquire.checkDateStart + " 00:00:00"), Convert.ToDateTime(inquire.checkDateEnd + " 23:59:59")))
                .WhereIF(!string.IsNullOrEmpty(inquire.daojiansjStart) && !string.IsNullOrEmpty(inquire.daojiansjEnd), p => SqlFunc.Between(p.daojiansj.Value, Convert.ToDateTime(inquire.daojiansjStart + " 00:00:00"), Convert.ToDateTime(inquire.daojiansjEnd + " 23:59:59")))
                .WhereIF(!string.IsNullOrEmpty(inquire.name), p => p.name.StartsWith(inquire.name))
                .WhereIF(!string.IsNullOrEmpty(inquire.orderStatus), p => p.orderStatus.StartsWith(inquire.orderStatus))
                .WhereIF(!string.IsNullOrEmpty(inquire.laiyuan), p => p.laiyuan.StartsWith(inquire.laiyuan))
                .OrderBy(p => p.createDt).ToList();
        }

        public bool updateState(TjTjyyjl tjTjyyjl)
        {
            return Db.Updateable(tjTjyyjl).UpdateColumns(it => new { it.jieshourenxm, it.jieshousj, it.orderStatus, it.daojiansj }).ExecuteCommand() >= 0;
            //return Db.Updateable(tjTjyyjl).WhereColumns(p => new { p.serialNumber }).ExecuteCommand() >= 0;
        }
    }
}